import {ExtraOptions, RouterModule, Routes} from '@angular/router';
import {NgModule} from '@angular/core';
import {
  NbAuthComponent,
} from '@nebular/auth';
import {LoginComponent} from './login/login.component';
import {AuthGuard} from './auth.guard';

const routes: Routes = [
  {
    path: 'company',
    loadChildren: './company/company.module#CompanyModule',
    canActivate: [AuthGuard],
    data: {role: 'company'}
  },
  {
    path: 'admin',
    loadChildren: './admin/admin.module#AdminModule',
    canActivate: [AuthGuard],
    data: {role: 'admin'}
  },
  {path: 'public', loadChildren: './public/public.module#PublicModule'},
  {path: 'auth', component: NbAuthComponent, children: [
      {
        path: 'login',
        component: LoginComponent,
      }
    ]},
  {path: '', redirectTo: 'auth/login', pathMatch: 'full'},
  {path: '**', redirectTo: 'public'},
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
